package ui.juego.mapamundi

import dominio.datos.Caracteristica
import org.uqbar.arena.bindings.PropertyAdapter
import org.uqbar.arena.layout.ColumnLayout
import org.uqbar.arena.layout.VerticalLayout
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.widgets.Label
import org.uqbar.arena.widgets.List
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.widgets.TextBox
import org.uqbar.arena.windows.Dialog
import org.uqbar.arena.windows.WindowOwner
import ui.juego.utilidades.IconUtils

class EditarCaracteristicaDialog extends Dialog<EditarCaracteristica> {
	
	new(WindowOwner owner, EditarCaracteristica model) {
		super(owner, model)
		title = "Editar Caracteristicas"
		iconImage = IconUtils.path
	}
	
	override protected createFormPanel(Panel mainPanel) {
		var Panel contentPanel = new Panel(mainPanel) => [
			layout = new VerticalLayout
		]
		
		new Label(contentPanel).text = "Caracteristicas: "
		new List<Caracteristica>(contentPanel) => [
			bindItemsToProperty("caracteristicas").adapter = new PropertyAdapter(Caracteristica, "dato")
			heigth = 50
			width = 150
			bindValueToProperty("caracteristicaSeleccionada")
		]
		
		new Button(contentPanel) => [
			caption = "Eliminar"
			setAsDefault
			onClick [ |
				modelObject.eliminarCaracteristicaSeleccionada
			]
		]
		
		var Panel addPanel = new Panel(contentPanel) => [
			layout = new ColumnLayout(2)
		]
		new TextBox(addPanel) => [
			bindValueToProperty("inputDato")
		]
		new Button(addPanel) => [
			caption = "Agregar"
			setAsDefault
			onClick [ |
					modelObject.agregarCaracteristica(new Caracteristica(modelObject.inputDato))
			]
		]
		
		new Button(contentPanel) => [
			caption = "Aceptar"
			onClick [ |
				close
			]
		]
	}
	
}